# Python 2.4 compatibility
try:
    from json import JSONEncoder
except ImportError:
    from simplejson import JSONEncoder
    
from chat.model.Action import Action
from django.db.models.query import QuerySet

class Response:

    _status = 0
    _errors = []
    _data = {}
    
    def __init__(self):
        self._status = 0
        self._errors = []
        self._data = {}
        
    def get_json(self):
        return  {
                 'status' : self._status,
                 'errors' : self._errors,
                 'data' : self._data,
                }

def serialize_response_data(o):
    if isinstance(o, QuerySet):
        return [serialize_response_data(x) for x in o]
    elif isinstance(o, Action):
        return Action.get_json(o)
    
    return JSONEncoder().default(o)